home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HTBasic 9.3
/
HTBasic 9.3.iso
/
83win
/
data1.cab
/
Basic_Plus_Examples
/
XYWDGT
< prev
Wrap
Text File
|
2001-03-02
|
5KB
|
159 lines
10 ! *****************************************************************
20 ! Example: XY GRAPH Widget
30 !
40 ! This program displays two random traces and allows you
50 ! to set various trace marker modes on the two traces.
60 !
70 ! ******************************************************************
80 !
90 RANDOMIZE INT(10^7*FRACT(TIMEDATE))
100 !
110 ! Define colors
120 !
130 INTEGER Black,White,Red,Yellow,Green,Cyan,Blue,Magenta
140 DATA 0,1,2,3,4,5,6,7
150 READ Black,White,Red,Yellow,Green,Cyan,Blue,Magenta
160 !
170 ! Variables Definitions:
180 !
190 INTEGER N
200 REAL R
210 !
220 ! Trace data buffers
230 !
240 REAL X(0:20),Y1(0:20),Y2(0:20)
250 !
260 ! SYSTEM MENU entries
270 !
280 DIM M$(0:5)[16]
290 DATA "No Markers","One Marker","Two Markers"
300 DATA "Delta Markers","Ratio Markers","Quit"
310 READ M$(*)
320 !
330 ! Variables to hold display coordinates
340 !
350 INTEGER D(1:4),Cursor,Dw,Dh,Gx,Gy,Gw,Gh
360 !
370 ! Get display size
380 !
390 GESCAPE CRT,3;D(*)
400 Dw=D(3)-D(1)
410 Dh=D(4)-D(2)
420 !
430 CLEAR SCREEN
440 !
450 ! Create GRAPH dimensions
460 !
470 Gw=Dw*.7
480 Gh=Dh
490 Gx=(Dw-Gw)/2
500 Gy=(Dh-Gh)/2
510 !
520 ! Build XY GRAPH.
530 !
540 ASSIGN @Graph TO WIDGET "XY GRAPH";SET ("VISIBLE":0)
550 CONTROL @Graph;SET ("SYSTEM MENU":M$(*),"MINIMIZABLE":1)
560 CONTROL @Graph;SET ("TITLE":" Example: XY GRAPH Widget")
570 CONTROL @Graph;SET ("SHARED X":1,"TRACE COUNT":2)
580 CONTROL @Graph;SET ("SHOW GRID":1,"TRACE BACKGROUND":White)
590 CONTROL @Graph;SET ("X":Gx,"Y":Gy+50,"WIDTH":Gw,"HEIGHT":.65*Gh)
600 !
610 ! Set X axis attributes
620 !
630 CONTROL @Graph;SET ("CURRENT AXIS":"X","ORIGIN":0,"RANGE":1)
640 !
650 ! Set Y axis attributes
660 !
670 CONTROL @Graph;SET ("CURRENT AXIS":"Y","ORIGIN":0,"RANGE":100)
680 !
690 ! Set up X data
700 !
710 FOR N=0 TO 20
720 X(N)=N/20
730 NEXT N
740 CONTROL @Graph;SET ("CURRENT TRACE":1,"X DATA":X(*))
750 !
760 ! Draw the curves
770 !
780 R=0
790 FOR N=0 TO 20
800 Y1(N)=R
810 R=R+6*RND
820 NEXT N
830 CONTROL @Graph;SET ("TRACE PEN":Red,"Y DATA":Y1(*))
840 !
850 R=0
860 FOR N=0 TO 20
870 Y2(N)=R
880 R=R+9*RND
890 NEXT N
900 CONTROL @Graph;SET ("CURRENT TRACE":2,"Y DATA":Y2(*))
910 CONTROL @Graph;SET ("TRACE PEN":Blue)
920 !
930 ! Loop and wait to exit
940 !
950 CONTROL @Graph;SET ("VISIBLE":1)
960 ON EVENT @Graph,"SYSTEM MENU" GOSUB Handler
970 DISP "WAITING"
971 WAIT 3
972 DISP "DONE"
973 CONTROL @Graph;SET ("STACKING ORDER":1)
980 LOOP
990 WAIT FOR EVENT
1000 END LOOP
1010 STOP
1020 !
1030 ! *************** End of Main Program **********************
1040 !
1050 ! This handler traps the SYSTEM MENU event and determines which
1060 ! entry caused the trap. It then performs the appropriate actions.
1070 !
1080 Handler: !
1090 STATUS @Graph;RETURN ("SYSTEM MENU EVENT":N)
1100 SELECT N
1110 !
1120 ! No markers
1130 !
1140 CASE 0
1150 CONTROL @Graph;SET ("MARKER":"NONE")
1160 !
1170 ! One marker
1180 !
1190 CASE 1
1200 CONTROL @Graph;SET ("MARKER":"ONE","MARKER1 TRACE":1)
1210 CONTROL @Graph;SET ("MARKER1 X":X(10),"MARKER1 Y":Y1(10))
1220 !
1230 ! Two markers
1240 !
1250 CASE 2
1260 CONTROL @Graph;SET ("MARKER":"TWO")
1270 CONTROL @Graph;SET ("MARKER1 TRACE":1,"MARKER2 TRACE":2)
1280 CONTROL @Graph;SET ("MARKER1 X":X(10),"MARKER2 X":X(10))
1290 CONTROL @Graph;SET ("MARKER1 Y":Y1(10),"MARKER2 Y":Y2(10))
1300 !
1310 ! Delta markers
1320 !
1330 CASE 3
1340 CONTROL @Graph;SET ("MARKER":"DELTA")
1350 CONTROL @Graph;SET ("MARKER1 TRACE":1,"MARKER2 TRACE":2)
1360 CONTROL @Graph;SET ("MARKER1 X":X(10),"MARKER2 X":X(10))
1370 CONTROL @Graph;SET ("MARKER1 Y":Y1(10),"MARKER2 Y":Y2(10))
1380 !
1390 ! Ratio markers
1400 !
1410 CASE 4
1420 CONTROL @Graph;SET ("MARKER":"RATIO")
1430 CONTROL @Graph;SET ("MARKER1 TRACE":1,"MARKER2 TRACE":2)
1440 CONTROL @Graph;SET ("MARKER1 X":X(10),"MARKER2 X":X(10))
1450 CONTROL @Graph;SET ("MARKER1 Y":Y1(10),"MARKER2 Y":Y2(10))
1460 !
1470 ! Exit program
1480 !
1490 CASE 5
1500 ASSIGN @Graph TO *! Delete XY GRAPH widget
1510 STOP
1520 END SELECT
1530 RETURN
1540 !
1550 END